<?PHP

ini_set('memory_limit','16M');

include '/home/cyberpower678/wikibot.classes.php';

$wpq = new wikipediaquery;
$wpapi = new wikipediaapi;
$wpi = new wikipediaindex;
$http = new http;

$user = "Cyberbot I";
$pass = file_get_contents('/home/cyberpower678/.password');

$wpapi->login($user,$pass);

if( !preg_match( '/(enable|yes|run|go|start)/i', $wpq->getpage("User:Cyberbot I/Run/RFAGraph") ) ) {
        die( "Bot is disabled.\n" );
}

//$wpi->forcepost('User:'.$user.'/Source',"The following is automatically generated by [[User:".$user."|]].\n\n\n\n* wikibot.classes.php is [[User:ClueBot/Source|here]].\n\n\n\n==Source to ".$user."==\n\n<pre>".htmlentities(file_get_contents(__FILE__))."</pre>\n\n\n\n~~~",'Automated source upload.'); /* Our source code, we force post this because this is *our* page, and it triggers the nobots. */

$text = $wpq->getpage('Wikipedia:Requests for adminship');
$result = array();
foreach (array(adminship,bureaucratship) as $rfx) {
        preg_match_all('/\{\{Wikipedia\:Requests for '.$rfx.'\/(.*)\}\}/', $text, $r);
        unset($r[1]);
        if ($rfx == 'adminship') {
                unset($r[0][0]);
                array_pop($r[0]);
        }
        print_r($r);
        $count = '0';
        foreach ($r[0] as $data) {
                $count = $count + 1;
        }
        $month = array(4=>0,5=>1,6=>2,7=>3,8=>4,9=>5,10=>6,11=>7,12=>8,1=>9,2=>10,3=>11);
        $days = array(28=>8.6,29=>8.3,30=>8,31=>7.7);
        $out = (240*$month[date("n")])+(date("j")*($days[date("t")])).",".($count * 50);
        echo $out."\n";
        array_push($result, $out);
}
print_r($result);
$code = $wpq->getpage('User:X!/RfA Graph');
$code = str_replace("<polyline stroke=\"#4A7EBB\" points=\"", "<polyline stroke=\"#4A7EBB\" points=\"\n".$result[0], $code);
$code = str_replace("<polyline stroke=\"#BE4B48\" points=\"", "<polyline stroke=\"#BE4B48\" points=\"\n".$result[1], $code);
file_put_contents('/home/cyberpower678/public_html/Graph of RfA and RfB.svg', $code);
$wpi->upload('/home/cyberpower678/public_html/Graph of RfA and RfB.svg','/home/soxred93/public_html/Graph of RfA and RfB.svg','Automated upload of graph');
$wpi->post('User:X!/RfA Graph', $code, 'Posting the code for an SVG graph (BOT EDIT)');

?>

